<template>
	<view :class="{bg141414:theme}" style="min-height: 100vh;">

		<view class="con pb200">
			<back title="确认订单"></back>
			<view class=" pg30-30 ra20 borderE1E1E1" >
				<view class="flex-a-i">
					<image mode="" class="wh180-180 ra20 image" :src="info.thumb"></image>
					<view class="ml15 flex1">
						<view class="flex-ju-b">
							<view  class="bold size30 one" style="max-width: 250rpx;">
								{{info.title}}
							</view>
							<view>
								#{{hao(info.nftId)}}
							</view>
						</view>
						<view class="size22  flex">
							<view  class="  mt10 mb10  color999">
								{{is_box==1?'盲盒':'数字藏品'}}
							</view>
						</view>
						<view class="size42 bold">
							<text class="size24">¥ </text> {{info.money_price / 100}}
						</view>
					</view>
				</view>
				
				<view class="flex-ju-b mt30 pt30" style="border-top: 1px dashed #E1E1E1;">
					<view class="color999">购买数量</view>
					<view :class="theme?'bg292929 colorfff':'bgfff'" class="flex-a-i  center ra30">1
						<!-- <view @click="tapbner(1)" class="wh48-48 flex-ju-c border-rF5F6F7">-</view>
					<view>
						<input class="width95 " disabled v-model="number" />
					</view>
					<view @click="tapbner(2)" class="wh48-48 flex-ju-c border-lF5F6F7">+</view> -->
					</view>
				</view>
				<view class="flex-ju-b mt40">
					<view  class="color999">合计支付</view>
					<view :class="theme?'colorfff':'color333'" class="">
						¥{{(info.money_price *number) / 100 }}
					</view>
				</view>
				
			</view>
			<view class=" pg30-30 ra20 mt25 borderE1E1E1" :class="theme?'bg292929 colorfff':'bgF5F6F7'">
				<view class="">
					<view class="bold color31">支付选择</view>
					<view class="flex-ju-b   mt40">
						<view class="size26">汇付天下</view>
						<view v-if="walletStatus.HF" :style="{border:theme?'1px solid #FF6E44' :''}" class="da wh28-28 border000 ra28 flex-ju-c">
							<view :style="{background:theme?'#FF6E44' :''}" class="xiao wh15-15 ra15 bg000"></view>
						</view>
						<view  class="srgb size24 pg10-20 ra10" v-else @click="tapmoney">
							开通钱包
						</view>
					</view>

				</view>
			</view>
			<view :class="theme?'bg292929 colorfff':'bgF5F6F7'" class="borderE1E1E1 pg30-30 ra20 mt25">
				<view class="bold">说明</view>
				<view class="color999 size26">
					<view class="mt15">1. 一个用户同时允许存在一笔待支付订单</view>
					<view class="mt10"> 2. 若您短时间未支付违约订单过多，将会被禁止购买一段时间</view>
				</view>
				<view class="bold mt30">购买说明</view>
				<view class="color999 size26">
					<view class="mt15">
						数字藏品交易仅限于20周岁(不含)以上、60周岁(含)以下，并已完成实名认证的中国大陆用户购买。由于不同属性的数字艺术有不同的二次交易规则，请您仔细阅读并同意相关规则后再进行相应操作，以避免不必要的损失。
						<view class="mt30">
							请注意，一旦数字藏品完成出售，不支持退货在购买之前，请仔细考虑您的购买决策。根据我国相关的法律要求，特定条件下的数字藏品的二次交易不支持任何形式的变相炒作。我们坚决反对数字藏品炒作、场外交易、欺诈，以及其他非法侵权行为。请您甄别上述涉嫌网络欺诈的行为并了解相关风险。
						</view>
					</view>
				</view>
			</view>
			<view class="flex-ju-c mt15">
				<view class="size24 flex-a-i color999">
					<radio style="transform:scale(0.7)" :borderColor="theme?'#FF6E44':'#000'" checked :activeBorderColor="theme?'#FF6E44':'#000'"
					:activeBackgroundColor="theme?'#FF6E44':'#000'" />
					我已阅读并同意<text class="color000">《购买须知》</text>
				</view>
			</view>

		</view>
		
		
		<view class="con">
			<view class="posifi width92vw bottom0">
				<view class="ra20 flex-ju-b pg30 bgfff height80"  style="box-shadow: 0rpx -8rpx 24rpx 0rpx rgba(0,0,0,0.06);">
					<view class="bold size62">
						<text class="size28">¥</text> {{(info.money_price *number) / 100 }}
					</view>
					<view @click="zhtapifu"class="bold wh330-100 bg000 colorfff ra20 flex-ju-c   size29  ">
						确认支付
					</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				theme: uni.getStorageSync('theme'),
				wallet: "HF",
				number: 1,
				info: {},
				walletStatus: {},
				is_box: "",
				timer: ""
			}
		},
		onLoad(option) {
			this.http(`resales/info/${option.uuid}`).then(res => {
				this.info = res.data
				this.is_box = res.data.is_box
			})

			this.http('wallet/walletStatus').then(res => {
				this.walletStatus = res.data
			})

			if (option.order_id) {
				this.http('order/check?order_id=' + option.order_id).then(ress => {
					if (ress.data.pay) {
						uni.reLaunch({
							url: "suu?order_id=" + e.order_id
						})
					} else {
						uni.showToast({
							title: "支付失败",
							icon: "none"
						})
					}
				})
			}
		},
		onHide() {
			uni.hideLoading()
			clearInterval(this.timer)
		},
		onUnload(){
			uni.hideLoading()
			clearInterval(this.timer)
		},
		methods: {

			goTimer(number) {
				this.http('resale/checkNumber', {
					number: number
				}).then(res => {
					// 0 任务进行中，继续循环 1 已分配订单，结束循环，2没有可分配的订单，结束循环，提示下单失败
					if (res.data.status == 0) {
						if (!this.timer) {
							this.timer = setInterval(() => {
								this.goTimer(number)
							}, 1000)
						}
						uni.showLoading({
							title: '抢单中'
						});
					}
					if (res.data.status == 1) {
						clearInterval(this.timer)
						this.topay(res.data.pay_url)
					}
					if (res.data.status == 2) {
						clearInterval(this.timer)
						uni.showToast({
							title: "下单失败",
							icon: "none"
						})
					}
				})
			},
			zhtapifu() {
				var url = 'pages/shichang/suu'
				// #ifdef APP-PLUS
					url = "back.html?erji=1"
				// #endif
				this.http('resale/buy', {
					product_id: this.info.product_id,
					resale_id: this.info.resale_id,
					url
				}, 'post').then(res => {
					uni.showLoading({
						title: '抢单中'
					});
					this.goTimer(res.data.number)
				})
			}
		}
	}
</script>

<style>

</style>